//
//  YZTwoBtnView.m
//  kuaiyi
//
//  Created by WGP on 16/5/4.
//
//

#import "YZTwoBtnView.h"

@interface YZTwoBtnView ()

@end
@implementation YZTwoBtnView

+(instancetype)twoBtnViewWith:(NSString *)title firstBtnTitle:(NSString *)firstTitle secondBtnTitle:(NSString *)secondTitle defaultSelected:(YZSelectedBtnType)selectedBtnType
{
    YZTwoBtnView *view = [[NSBundle mainBundle] loadNibNamed:@"YZTwoBtnView" owner:nil options:nil].lastObject;
    view.title.text = title;
    [view.firstBtn setTitle:firstTitle forState:UIControlStateNormal];
    [view.secondBtn setTitle:secondTitle forState:UIControlStateNormal];
    if (selectedBtnType == YZSelectedBtnTypeLeft) {
        
        [view btnDidClick:view.secondBtn];
    }
    else if (selectedBtnType == YZSelectedBtnTypeRight)
    {
        [view btnDidClick:view.firstBtn];
    }
    return view;
}

- (IBAction)btnDidClick:(UIButton *)sender {
    
    if (sender == self.currentSelectedBtn) {
        return ;
    }
    
    self.currentSelectedBtn.selected = NO;
    self.currentSelectedBtn = sender;
    self.currentSelectedBtn.selected = YES;
    
    if ([self.delegate respondsToSelector:@selector(isHiddenMethodViewWith:)]) {
        [self.delegate isHiddenMethodViewWith:self];
    }
}



@end
